package de.cartoonboy;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;

import javax.microedition.khronos.opengles.GL10;

import de.elenore.render.RenderInterface;
import de.elenore.util.GameActivity;

public class RenderMe implements RenderInterface {

	public FloatBuffer vertices;

	@Override
	public void setup(GameActivity g, GL10 gl) {
		ByteBuffer buffer = ByteBuffer.allocateDirect(3 * 4 * 3);
		buffer.order(ByteOrder.nativeOrder());
		vertices = buffer.asFloatBuffer();

		vertices.put(-0.5f);
		vertices.put(-0.5f);
		vertices.put(0);

		vertices.put(0.5f);
		vertices.put(-0.5f);
		vertices.put(0);

		vertices.put(0);
		vertices.put(0.5f);
		vertices.put(0);

		vertices.position(0);

	}

	@Override
	public void mainLoop(GameActivity g, GL10 gl) {
		gl.glViewport(0, 0, g.getWidth(), g.getHeight());
		gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
		gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
		gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertices);
		gl.glDrawArrays(GL10.GL_TRIANGLES, 0, 3);

	}

}
